home *** CD-ROM | disk | FTP | other *** search
-
- /********************************************
- **** Core Class V1.1 © 1993-94 Yves Schmid & Alia Development
- ****
- **** CoreNode.h
- ****
- **** Authors: Yves Schmid and Odorico von Susani
- **** Created: 14 November 1993
- **** Modified: 08 August 1994
- **** Compatible: C++
- **** Version: 1.1
- **** Description: This class is part of the linked list system of the Core class system.
- **** When you create a class which must be linked to a CoreList, you
- **** must create a superclass of CoreNode. A CoreNode contains a pointer
- **** on the next node (or NULL), a pointer on the previous node (or NULL) and
- **** a pointer on his CoreList.
- ****
- **** When you build a CoreNode you give the constructor a pointer
- **** on a CoreList. If you don't give a CoreList, the node will remain
- **** unlinked.
- ****
- **** A previously built CoreNode can be linked to a CoreList with
- **** the "setlist" method . "Setlist" is smart enough to unlink
- **** the CoreNode if it has already been linked to another list.
- **** You can pass NULL to "setlist" if you just want to unlink
- **** your node (same as calling "remove").
- ****
- **** The destructor unlinks the node from his list for you. You
- **** don't have to unlink a node before destroying it.
- ****
- **** For parsing a list you can use this code:
- ****
- **** for(CoreNode *n = list->getfirst();n;n=n->getnext()) {...}
- ****
- **** You may want to use the message system:
- ****
- **** list->docmd(CCMD_EXAMPLE,CCF_NODES); // From a CoreList
- **** node->docmd(CCMD_EXAMPLE,CCF_NODES); // From a CoreNode
- ****
- ****
- **** When a node is duplicated it is added to the same CoreList as
- **** the original node. You can remove it or link it to another
- **** list using the "setlist" method.
- ****
- *************************/
-
-
- #ifndef CoreNode_H
- #define CoreNode_H
-
-
- #include "Core.h"
- #include "CoreList.h"
-
- class CoreList;
- class CoreHead;
-
- //.......................................
- // CoreNode
-
- class CoreNode: public Core
- {
-
- //***********************************************************
- //.............. P U B L I C M E T H O D S.................
-
- public:
-
-
- CoreNode(void); // No link
- CoreNode(CoreList *); // Linked to a CoreList
-
- virtual ~CoreNode(void);
-
-
-
- virtual void setlist(CoreList *); // Link to a list
- virtual void sethead(CoreHead *ahead, long entry); // Link to a head (See "CoreHead.h")
-
- virtual void setlist(CoreList *, long position); // Link to a list at a position
-
- virtual void setsamelistas(CoreNode *, Boolean insertbefore =FALSE);
- // Link to the same list as the passed
- // CoreNode. If "insertbefore" is TRUE
- // object is inserted before the passed
- // CoreNode else it is linked after.
-
-
-
- inline CoreList *getlist(void) const {return list;} // return list
- inline CoreNode *getnext(void) const {return next;} // return next
- inline CoreNode *getprevious(void) const {return previous;} // return previous
-
-
-
- virtual void remove(void); // Unlink from his CoreList
-
- virtual Core *duplicate(void); // Duplicate. If this object has a list, the
- // duplicated object is linked to the same
- // list. Use "remove" if you want to unlink
- // the duplicated object.
-
- //***********************************************************
-
-
- public:
-
- //..........................................................
- // You should not call the following methods!
-
- inline void setlistptr(CoreList *a){list = a;}
- inline void setprevious(CoreNode *un) {previous = un;}
- inline void setnext(CoreNode *un) {next = un;}
-
-
- virtual void sendcmd(long cmd, short flags=0, void *info=NULL, // (Only for internal use)
- short t=0, void *parent=NULL);
-
- virtual void copyfrom(Core *uo); // The magic duplication system (see "Core.h")
-
- //..........................................................
-
-
- private:
-
- CoreNode *next; // Link
- CoreNode *previous;
- CoreList *list; // Its list or NULL
-
-
- void linknode(void); // Link a node (internal use only)
-
- };
-
-
- #endif
-
-